//
//	HOME AUTOMATION GATEWAY PROJECT
//
//  (c) 2008 mocom software GmbH & Co KG 
//	for European Microsoft Innovation Center
//
//  $Author: volker $
//  $Date: 2009-02-26 16:55:56 +0100 (Do, 26. Feb 2009) $
//  $Revision: 276 $
//
//  Microsoft dotNetMF Project
//  Copyright ©2001,2002,2003,2004 Microsoft Corporation
//  One Microsoft Way, Redmond, Washington 98052-6399 U.S.A.
//  All rights reserved.
//  MICROSOFT CONFIDENTIAL
//
//-----------------------------------------------------------------------------

#include "tinyhal.h"

//--//

#ifndef _DRIVERS_DISPLAY_DD160128FC2A_H_
#define _DRIVERS_DISPLAY_DD160128FC2A_H_ 1

//////////////////////////////////////////////////////////////////////////////

#define DD160128FC2A_SCREEN_WIDTH              160
#define DD160128FC2A_SCREEN_HEIGHT             128
#define DD160128FC2A_BUS_WIDTH             		16
#define DD160128FC2A_BITS_PER_PIXEL            	16

//////////////////////////////////////////////////////////////////////////////

struct DD160128FC2A_Driver
{
    static const int    c_Tab_Width         = 4;
    static const int    c_Font_Width        = 8;
    static const int    c_Font_Height       = 12;    
	
	static const int 	c_bits_per_pixel    = DD160128FC2A_BITS_PER_PIXEL;
	
	static const int 	c_size_in_pixels 	= DD160128FC2A_SCREEN_WIDTH*DD160128FC2A_SCREEN_HEIGHT;
	static const int	c_size_in_bytes   	= sizeof(UINT16) * c_size_in_pixels;
 
	static const int	c_text_columns  	= DD160128FC2A_SCREEN_WIDTH / c_Font_Width;
	static const int	c_text_rows  		= DD160128FC2A_SCREEN_HEIGHT / c_Font_Height;
	
	static const int	c_columns  			= DD160128FC2A_SCREEN_WIDTH;
	static const int	c_rows  			= DD160128FC2A_SCREEN_HEIGHT;
	
	static const int 	c_pixel_in_word	    = (sizeof(UINT32)*8) / DD160128FC2A_BITS_PER_PIXEL;
	
    //--//

    UINT32 m_cursor;
	
	SPI_CONFIGURATION SpiConfig;
	
    //--//
    
    static BOOL Initialize();

    static BOOL Uninitialize();

	static UINT32 *GetFrameBuffer();

	static void PowerSave( BOOL On );

    static void Clear();

    static void BitBltEx( int x, int y, int width, int height, UINT32 data[] );

    static void BitBlt( int width, int height, int widthInWords, UINT32 data[], BOOL fUseDelta );
	
    static void WriteChar         ( unsigned char c, int row, int col );
    
    static void WriteFormattedChar( unsigned char c                   );
	
	static INT32 GetWidth();

	static INT32 GetHeight();
	
	static INT32 GetBitsPerPixel();
	
	static INT32 GetPixelClockDivider();
	
private:
	static void SendPixel(UINT16 *data, unsigned pixel);
	static void SetPixelPos(UINT16 x, UINT16 y);
	static void SetPixel(UINT16 x, UINT16 y, UINT16 *data);
	static void WriteString(char *str);
	static UINT8 SPI_Write_Data(UINT8 data);
	static void SPI_Write_Command(UINT8 cmd);
	static UINT8 SPI_Write_Command_Data(UINT8 cmd, UINT8 data);
};

extern DD160128FC2A_Driver g_DD160128FC2A_Driver;


#endif  // _DRIVERS_DISPLAY_DD160128FC2A_H_
